package date;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * @author lyy
 * @date 2021/12/20
 */
public class DateFormat {
    public static void main(String[] args) {
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
        LocalDateTime now = LocalDateTime.now();
        String format = formatter.format(now);
        LocalDateTime timeStr = LocalDateTime.parse("2021-12-20 10:10", formatter);
        System.out.println(now);
        System.out.println(format);
        System.out.println(timeStr);
    }
}
